package com.ipc.app.web.controller;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.ipc.app.biz.InformationBiz;
import com.ipc.app.constants.InformationTypeConstants;
import com.ipc.app.constants.SessionConstants;
import com.ipc.app.model.Information;
import com.ipc.app.model.Paginator;

@Controller
@RequestMapping(value = "/jsp/myReleaseInformation.do")
public class MyReleaseInformationAction {

	@Autowired
	private InformationBiz informationBiz;

	@RequestMapping(method = RequestMethod.GET)
	public String getMyReleaseInformation(ModelMap model,
			HttpServletRequest request, String pageIndex) {

		String userID = (String) request.getSession().getAttribute(
				SessionConstants.LOGIN_USER_ID);
		if (StringUtils.isBlank(pageIndex)) {
			pageIndex = "1";
		}
		Paginator<Information> informations = informationBiz
				.getInformationByUser(userID,
						InformationTypeConstants.CAR_OWNER, Integer
								.valueOf(pageIndex));
		model.addAttribute("informations", informations);
		return "myReleaseInformation";
	}
}
